//
//  CJSearchView.swift
//  SinaWeibo
//
//  Created by 程建 on 16/9/22.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit
//让定义的圆角属性时时刷新,加一个@IBDesignable
@IBDesignable class CJSearchView: UIButton {

    /* @IBInspectable var cornerRadius: CGFloat {
    
        //IBAction
        //IBOutlet
        //@IBInspectable 定义可视化属性
        //@IBDesignable 让属性时时刷新
        set{
            //设置圆角的属性
            self.layer.cornerRadius = newValue
            self.layer.masksToBounds = newValue > 0
            
        }
        
        get{
            return layer.cornerRadius
        }
    
    }
 */
    
    
    //定义类方法,加载视图nil文件
    class func loadSearchView() ->CJSearchView {
        
        let nib = UINib(nibName: "CJSearchView", bundle: nil)
        let searchView = nib.instantiate(withOwner: nil, options: nil).last as! CJSearchView
        
        return searchView
    }
    
    //加载xib会被调用
    override func awakeFromNib() {
        //设置图片,文字的内边距
        self.imageEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0)
        self.titleEdgeInsets = UIEdgeInsetsMake(0, 15, 0, 0)
        
        //通过代码设置宽度
        self.bounds.size.width = UIScreen.main.bounds.width
        self.bounds.size.height = 36
        
        //设置圆角
  //      self.layer.cornerRadius = 17
  //      self.layer.masksToBounds = true
    }

}
